package com.pine.springboot.controller;

import com.pine.springboot.domain.Article;
import com.pine.springboot.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;


@Controller
public class ArticleController {

    @Autowired
    ArticleService articleService;

    @GetMapping("/index")
    public String index(Model model,
                        @RequestParam (value = "pageNum",defaultValue = "1") int pageNum ,
                        @RequestParam (value = "pageLimit",defaultValue = "2") int pageLimit){

        Page<Article> articleList = articleService.getArticleList(pageNum,pageLimit);

        model.addAttribute("articleList",articleList);


        return "client/index";
    }



}
